package com.ruoyi.web.controller.performance;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.performance.domain.Scoring;
import com.ruoyi.performance.service.IScoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教师考核打分Controller
 * 
 * @author eden
 * @date 2023-05-20
 */
@RestController
@RequestMapping("/performance/scoring")
public class ScoringController extends BaseController
{
    @Autowired
    private IScoringService scoringService;

    /**
     * 查询教师考核打分列表
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(Scoring scoring)
    {
        startPage();
        List<Scoring> list = scoringService.selectScoringList(scoring);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('performance:scoring:listSealf')")
    @GetMapping("/listSealf")
    public void listSealf()
    {

         scoringService.listSealf();

    }



    /**
     * 导出教师考核打分列表
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:export')")
    @Log(title = "教师考核打分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Scoring scoring)
    {
        List<Scoring> list = scoringService.selectScoringList(scoring);
        ExcelUtil<Scoring> util = new ExcelUtil<Scoring>(Scoring.class);
        util.exportExcel(response, list, "教师考核打分数据");
    }

    /**
     * 获取教师考核打分详细信息
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:query')")
    @GetMapping(value = "/{Id}")
    public AjaxResult getInfo(@PathVariable("Id") Long Id)
    {
        return success(scoringService.selectScoringById(Id));
    }

    /**
     * 新增教师考核打分
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:add')")
    @Log(title = "教师考核打分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Scoring scoring)
    {
        return toAjax(scoringService.insertScoring(scoring));
    }

    /**
     * 修改教师考核打分
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:edit')")
    @Log(title = "教师考核打分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Scoring scoring)
    {
        return toAjax(scoringService.updateScoring(scoring));
    }
    /**
     * 批量化修改教师考核打分
     */
    @PutMapping("/oneSelf")
    public AjaxResult oneSelf(@RequestBody List<Scoring> scoringlist)
    {
        return toAjax(scoringService.oneSelf(scoringlist));

    }
    @PutMapping("/other")
    public AjaxResult other(@RequestBody List<Scoring> scoringlist)
    {
        return toAjax(scoringService.other(scoringlist));

    }


    /**
     * 删除教师考核打分
     */
    @PreAuthorize("@ss.hasPermi('performance:scoring:remove')")
    @Log(title = "教师考核打分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Ids}")
    public AjaxResult remove(@PathVariable Long[] Ids)
    {
        return toAjax(scoringService.deleteScoringByIds(Ids));
    }
}
